const ADD_GUN = "ADD_GUN";
const SUB_GUN = "SUB_GUN";


// reducer
export function counter(state=0, action) {

    switch (action.type){
        case ADD_GUN:
            return state + 1;
        case SUB_GUN:
            return state - 1;
        default:
            return 10;
    }
}

// action creator
export function addGun(){
    return {type: ADD_GUN};
}
export function subGun(){
    return {type: SUB_GUN};
}
//拖两天再给。使用thunk返回一个函数，过两秒之后再手动dispatch
export function addGunAysc() {
    return dispatch => {
        setTimeout(()=>{
            dispatch(addGun());
        },2000);
    }
}
